﻿using DoNet.Bpmn.Core.Enums;
using DoNet.Bpmn.Core.Utils;
using DoNet.Bpmn.Core.Vo;
using Microsoft.Extensions.Logging;

namespace DoNet.Bpmn.Adaptor.BpmnElement
{
    public class BpmnElementDirectLeaderAdaptor : BpmnElementAdaptor
    {
        private readonly ILogger<BpmnElementDirectLeaderAdaptor> _logger;

        public BpmnElementDirectLeaderAdaptor(ILogger<BpmnElementDirectLeaderAdaptor> logger)
        {
            _logger = logger;
        }

        protected override BpmnConfCommonElementVo GetElementVo(BpmnNodePropertysVo property, BpmnNodeParamsVo paramsVo, int elementCode, string elementId)
        {
            // Get the assignee and assignee name or initialize with default values
            var bpmnNodeParamsAssigneeVo = paramsVo.Assignee ?? new BpmnNodeParamsAssigneeVo();
            string assignee = bpmnNodeParamsAssigneeVo.Assignee;
            string assigneeName = bpmnNodeParamsAssigneeVo.AssigneeName;

            var singleAssigneeMap = new Dictionary<string, string>
            {
                { assignee, assigneeName }
            };

            return BpmnElementUtils.GetSingleElement(elementId, bpmnNodeParamsAssigneeVo.ElementName,
                $"directLeader{elementCode}", assignee, singleAssigneeMap);
        }

        public override void SetSupportBusinessObjects()
        {
            ((IAdaptorService)this).AddSupportBusinessObjects(NodePropertyEnum.NODE_PROPERTY_DIRECT_LEADER);
        }
    }
}
